#include "HumanManager.h"


HumanManager::HumanManager( DuiLib::CPaintManagerUI& pm )
	:m_pm(pm)
	,m_pHumanList(NULL)
	,m_pTabItem(NULL)
	,m_pDetailDlg(NULL)
{

}

void HumanManager::Init()
{
	DuiLib::CDialogBuilder builder;
	m_pTabItem = builder.Create(_T("HumanManager.xml"), NULL, NULL, &m_pm);
	DuiLib::CControlUI* pBtn = m_pm.FindSubControlByName(m_pTabItem, _T("BtnHumanDetail"));
	pBtn->OnNotify += DuiLib::MakeDelegate(this, &HumanManager::OnDetail);
	//m_pTabMenu = builder.Create(_T("HumanManagerMenu.xml"), NULL, NULL, &m_pm);
	m_pHumanList = dynamic_cast<DuiLib::CListUI*>(m_pm.FindSubControlByName(m_pTabItem, _T("HumanList")));
	m_pHumanList->SetTextCallback(this);
	DuiLib::CListTextElementUI* pElement = new DuiLib::CListTextElementUI;
	m_pHumanList->Add(pElement);
	pElement = new DuiLib::CListTextElementUI;
	m_pHumanList->Add(pElement);
	pElement = new DuiLib::CListTextElementUI;
	m_pHumanList->Add(pElement);
}

DuiLib::CControlUI* HumanManager::GetTabItem()
{
	return m_pTabItem;
}

bool HumanManager::OnDetail( void* param )
{
	DuiLib::TNotifyUI* msg = (DuiLib::TNotifyUI*)param;
	if(msg->sType == _T("click"))
	{
		if(m_pDetailDlg == NULL)
			m_pDetailDlg = new DetailDlg(m_pm);
		m_pDetailDlg->ShowDetail(_T("Test"));
	}

	return true;
}
